<?php

/**
 * @author      Dennis Greulich / Pionier 
 * 
 * @package AllianzTool3
 * @version $Id: status.php 3 2010-01-24 09:20:21Z allytools $
 * @copyright (c) 2009 Allytools
 * @license http://creativecommons.org/licenses/by-sa/3.0/de/
 *
 */

//Includes
require ("./config.php");
require ("./auth.php");
require ("./config.php");
require ("./system/functions.php");
require ("./system/class/mysql.class.php");
require ("./system/libs/Smarty.class.php");

$style = $_SESSION['style'];
$lang = $_SESSION['language'];

include './language/'.SYS_LANG.'/status.php';

$db = new mysql(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();

// Systeme Gesamt
$sql = "SELECT COUNT(galaxy) as anzahl FROM `".TABLE_GALAXIE."`";
$res = mysql_query($sql);
$line = mysql_fetch_object($res);
$anzahl = $line->anzahl / 15; // 15 rows for each system

// Neue Systeme
$query  = "SELECT count(*) as anzahl FROM `".TABLE_GALAXIE."` WHERE planet=1 AND DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= last_update";
$res = mysql_query($query);
$line = mysql_fetch_object($res);
$anzahl_new = $line->anzahl;

// alte Systeme
$query  = "SELECT count(*) as anzahl FROM `".TABLE_GALAXIE."` WHERE planet=1 AND DATE_SUB(CURDATE(),INTERVAL 30 DAY) > last_update";
$res = mysql_query($query);
$line = mysql_fetch_object($res);
$anzahl_old = $line->anzahl;

// Anzahl User
$sql = "SELECT COUNT(*) as anzahl FROM `".TABLE_USER."`";
$res = mysql_query($sql);
$line = mysql_fetch_object($res);
$anzahl_user = $line->anzahl;

// Anzahl Notizen
$sql = "SELECT COUNT(*) as anzahl FROM `".TABLE_NOTICES."`";
$res = mysql_query($sql);
$line = mysql_fetch_object($res);
$anzahl_notices = $line->anzahl;

// Anzahl Stats-Player
$query  = "SELECT count(*) as anzahl FROM `".TABLE_PLAYER."`";
$res = mysql_query($query);
$line = mysql_fetch_object($res);
$stats_player = $line->anzahl;

// Anzahl Ally-Player
$query  = "SELECT count(*) as anzahl FROM `".TABLE_ALLY."`";
$res = mysql_query($query);
$line = mysql_fetch_object($res);
$stats_ally = $line->anzahl;

// Anzahl KB
$query  = "SELECT count(*) as anzahl FROM `".TABLE_KB."`";
$res = mysql_query($query);
$line = mysql_fetch_object($res);
$kb = $line->anzahl;

// Anzahl Spio
$query  = "SELECT count(*) as anzahl FROM `".TABLE_SPIO."`";
$res = mysql_query($query);
$line = mysql_fetch_object($res);
$spio = $line->anzahl;

// Anzahl U-Mode
$query  = "SELECT count(*) as anzahl FROM `".TABLE_PLAYER."` WHERE vacation='true'";
$res = mysql_query($query);
$line = mysql_fetch_object($res);
$umode = $line->anzahl;

// Anzahl Monde
$query  = "SELECT count(*) as anzahl FROM `".TABLE_GALAXIE."` WHERE moon='true'";
$res = mysql_query($query);
$line = mysql_fetch_object($res);
$moon = $line->anzahl;

// Anzahl Planeten
$query  = "SELECT count(*) as anzahl FROM `".TABLE_GALAXIE."` g, `".TABLE_PLAYER."` p WHERE g.player_id = p.id AND banned='false' AND vacation='false' AND noob='false'";
$res = mysql_query($query);
$line = mysql_fetch_object($res);
$planets = $line->anzahl;

$db->close();

// Template
$tpl = new Smarty; 

$tpl->assign('title', $l_title);
$tpl->assign('style',$style); //Style laden
$tpl->assign('lang',$lang); //Sprache laden
$tpl->assign('sys_ges_wert', $anzahl);
$tpl->assign('sys_new', $anzahl_new);
$tpl->assign('sys_old', $anzahl_old);
$tpl->assign('user', $anzahl_user);
$tpl->assign('notices', $anzahl_notices);
$tpl->assign('stats_player', $stats_player);
$tpl->assign('stats_ally', $stats_ally);
$tpl->assign('kb', $kb);
$tpl->assign('spio', $spio);
$tpl->assign('umode', $umode);
$tpl->assign('moon', $moon);
$tpl->assign('planets', $planets);
$tpl->debugging = TPL_DEBUG; //Debuggen
$tpl->display('status.html'); //Template ausgeben

?>